﻿using System;
using TiaoTiaoCode.Common.Extensions;

namespace TiaoTiaoCode.AutoUpdate.Common.Dtos
{
    /// <summary>
    /// 程序详细文件列表
    /// </summary>
    public class MainProgramFileDetailView
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="updateTime"></param>
        /// <param name="filePath"></param>
        /// <param name="fileVersion"></param>
        public MainProgramFileDetailView(string fileName, DateTime updateTime, string filePath, string fileVersion)
        {
            FileName = fileName;
            UpdateTime = updateTime;
            FilePath = filePath;
            FileVersion = fileVersion;

            var dto = FileVersion.TiaoTiaoParseDotNetVersion();
            Major = dto.Major;
            Version = dto.Version;
            MinorNumber = dto.MinorNumber;
            BuildNumber = dto.BuildNumber;
            CustomVersion = dto.CustomVersion;

            IsNeedUpdate = false;
        }

        /// <summary>
        /// 文件名
        /// </summary>
        public string FileName { get; set; }

        /// <summary>
        /// 文件修改时间
        /// </summary>
        public DateTime UpdateTime { get; set; }

        /// <summary>
        /// 文件路径
        /// </summary>
        public string FilePath { get; set; }

        /// <summary>
        /// 文件版本号
        /// </summary>
        public string FileVersion { get; set; }

        /// <summary>
        /// 主版本
        /// </summary>
        public int Major { get; set; }

        /// <summary>
        /// 子版本
        /// </summary>
        public int Version { get; set; }

        /// <summary>
        /// 修正版本号
        /// </summary>
        public int MinorNumber { get; set; }

        /// <summary>
        /// 编译版本号
        /// </summary>
        public int BuildNumber { get; set; }

        /// <summary>
        /// 用户自定义说明版本号
        /// </summary>
        public string? CustomVersion { get; set; }

        /// <summary>
        /// 文件是否需要更新
        /// </summary>
        public bool IsNeedUpdate { get; set; }
    }
}
